//
//  MHOrderViewController.m
//  M-Saler
//
//  Created by Teresa on 2020/5/21.
//  Copyright © 2020 Teresa. All rights reserved.
//

#import "MHOrderViewController.h"
#import "HLSegmentBarVC.h"
#import "MHOrderListController.h"
#import "MHOrderListRequest.h"
#import "MHOrderInfoModel.h"

@interface MHOrderViewController ()

@property (nonatomic, strong) HLSegmentBarVC *segmentBarVC;

@end

@implementation MHOrderViewController
- (HLSegmentBarVC *)segmentBarVC {
    if (!_segmentBarVC) {
        HLSegmentBarVC *vc = [[HLSegmentBarVC alloc] init];
        [self addChildViewController:vc];
        vc.segmentBar.backgroundColor = [UIColor colorWithHexStr:@"FFFFFF"];
        vc.segmentBar.frame = CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, 35);
        vc.view.frame = CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, self.view.frame.size.height-50);

        _segmentBarVC = vc;
    }
    return _segmentBarVC;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"漫时光";
    self.navigationController.navigationBar.translucent = NO;
    [self.view addSubview:self.segmentBarVC.view];
   
    
    NSArray *items = @[@"新订单",@"进行中",@"已完成"];
    
    MHOrderListController *vc0 = [[MHOrderListController alloc]initWithStyle:UITableViewStylePlain];
    vc0.pageType = MHOrderPageTypeNew;
    MHOrderListController *vc1 = [[MHOrderListController alloc]initWithStyle:UITableViewStylePlain];
    vc1.pageType = MHOrderPageTypeInProcess;
    MHOrderListController *vc2 = [[MHOrderListController alloc]initWithStyle:UITableViewStylePlain];
    vc2.pageType = MHOrderPageTypeMHDone;
    NSArray *controllers = @[vc0,vc1,vc2];

    [self.segmentBarVC setUpWithItems:items childVCs:controllers];
    
    [self.segmentBarVC.segmentBar updateWithConfig:^(HLSegmentBarConfig *config) {
        config.itemSelectColorBlock(MH_Red_Color);
        config.indicatorColorBlock(MH_Red_Color);
        config.itemNormalColorBlock([UIColor colorWithHexStr:@"354052"]);
        config.segmentBarBackColorBlock([UIColor colorWithHexStr:@"FFFFFF"]);
//        config.indicatorExtraWidthBlock(-4);
    }];

}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear: animated];
    self.navigationController.navigationBar.shadowImage = [UIImage new];
    [self.navigationController setNavigationBarHidden:NO];
}



@end
